package com.wiscamp.ninechapters.tags.domain.models;

import cube.ddd.domain.Entity;
import lombok.Data;

import java.io.Serial;
import java.time.LocalDateTime;

/**
 * 标签
 */
@Data
public class Tag implements Entity {
    /**
     * 标签编号
     */
    private long tagId = 0;

    /**
     * 应用编号
     */
    private long applicationId = 0;

    /**
     * 标签组名称
     */
    private String groupName = "";

    /**
     * 标签代码
     */
    private String tagCode = "";

    /**
     * 标签名称
     */
    private String tagName = "";

    /**
     * 备注
     */
    private String remark = "";

    /**
     * 是否可用
     */
    private boolean enabled = true;

    /**
     * 是否删除
     */
    private boolean deleted = false;

    /**
     * 创建用户
     */
    private long creatorId = 0;

    /**
     * 创建时间
     */
    private LocalDateTime creationTime;

    /**
     * 编辑用户
     */
    private long modifierId = 0;

    /**
     * 编辑时间
     */
    private LocalDateTime modificationTime;

    private String creatorName = "";

    private String modifierName = "";

    public void enable() {
        if (!this.enabled) {
            this.enabled = true;
        }
    }

    public void disable() {
        if (this.enabled) {
            this.enabled = false;
        }
    }

    public void delete() {
        if (!this.deleted) {
            this.deleted = true;
        }
    }

    public void createBy(long operatorId) {
        this.creatorId = operatorId;
        this.creationTime = LocalDateTime.now();
        this.modifierId = operatorId;
        this.modificationTime = LocalDateTime.now();
    }

    public void updateBy(long operatorId) {
        this.modifierId = operatorId;
        this.modificationTime = LocalDateTime.now();
    }
}